go to previous page   go to home page   go to next page

Answer:

No. Any order would work.


Compiling and Running the Program
(Separate Source Files)

A better way to organize the program is to put each class and interface into its own file. If this is done, each class can be made public.

//File: Taxable.java
interface Taxable
{
}

//File: Goods.java
public class Goods
{
}

//File: Food.java
public class Food extends Goods
{
}

//File: Toy.java
public class Toy extends Goods implements Taxable
{
}

//File: Book.java
public class Book extends Goods implements Taxable
{
}

//File: Store.java
public class Store
{
}

Compile and run in the usual way. The Java compiler looks for and compiles all the files it needs to compile Store.java. The interface, also, compiles into a separate file, Taxable.class

C:\Temp>javac Store.java
C:\Temp>java Store
item: bubble bath price: 1.4
item: ox tails price: 4.45
calories: 1500.0
item: Legos price: 54.45
minimum age: 8
Tax is: 3.267

item: Emma price: 24.95
author: Austen
Tax is: 1.4969999999999999

C:\Temp>dir 

08/22/2014  07:52 AM     811 Book.class
08/22/2014  07:47 AM     347 Book.java
08/22/2014  07:53 AM     708 Food.class
08/22/2014  07:52 AM     265 Food.java
08/22/2014  07:52 AM     750 Goods.class
08/22/2014  07:46 AM     355 Goods.java
08/22/2014  07:53 AM   1,157 Store.class
08/22/2014  07:44 AM     504 Store.java
08/22/2014  07:52 AM    179 Taxable.class
08/22/2014  07:50 AM    200 Taxable.java
08/22/2014  07:52 AM    825 Toy.class
08/22/2014  07:52 AM    443 Toy.java
       12 File(s)          6,544 bytes

       C:\Temp>

QUESTION 17: